// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require(CONFIG.BasePath + "js/enterprise/base");
    var approve_upload_css = require("./approve_commit.css");
    var flag = false;
    var businessLicenceImage;
    var certificateImage;
    var legalPersonFrontImage;
    var legalPersonBackImage;
    var creditReportImage;
    var qualificationsImage;
	var imgObj;
	var variable;
	var tools = require("tools");
	var dialog = require("dialog");
    var enterpriseId;
    
    var init = function(page){
    	enterpriseId = page.params.enterpriseId;
    	base.alert(2,"资质认证通过后，请重新登录系统！");
		initEvent();
		
		layer.confirm('是否确认提交企业资质认证，提交后将无法再次修改。', {
		  btn: ['确定','取消'] //按钮
		}, function(){
		  submitEnterprise();
		}, function(){
		});
    };
	var initEvent = function(){
		//返回账户中心
		$(".account_center").attr("href", "../account/account.html");
		
		$(".submitEnterprise").unbind("click").click(function(){
			layer.confirm('是否确认提交企业资质认证，提交后将无法再次修改。', {
			  btn: ['确定','取消'] //按钮
			}, function(){
			  submitEnterprise();
			}, function(){
			});
		});
    };
    
    //提交企业资质
    var submitEnterprise = function(){
		base.fnAjax({
			action: "submitEnterprise.json",
			async: false,
			oData: {
				enterpriseId: enterpriseId
            }, //传递参数
            fnSuccess: function(data) {
                if (data.status == 200) {
//              	base.alert(1, "提交成功！");
//              	location.href="../account/account.html";
                	location.href="../account/account.html#account/enterpriseDetail";
                } else {
//              	base.alert(3, data.message);
                	location.href="../account/account.html#account/enterpriseDetail";
                }
            }
		});
	};
	
    return {
        init:init
    };
});